# -*- coding: utf-8 -*- 
# @project : 《Atcoder》
# @Author : created by bensonrachel on 2021/12/20
# @File : 33.D - Weak Takahashi.py
# https://atcoder.jp/contests/abc232/tasks/abc232_d
def dp_solve():
    dp = [[0]*(w) for _ in range(h)]
    dp[0][0] = 1
    for i in range(1,w):
        if grid[0][i] == '.':
            dp[0][i] = dp[0][i-1] + 1
        else:
            dp[0][i] = -101
    for i in range(1,h):
        if grid[i][0] == '.':
            dp[i][0] = dp[i-1][0] + 1
        else:
            dp[i][0] = -101
    for i in range(1,h):
        for j in range(1,w):
            if grid[i][j] == '.':
                dp[i][j] = max(dp[i][j-1],dp[i-1][j])+1
            else:
                dp[i][j] = -(h*w + 1)#会出现堵门的情况，所以要设得比全部格子数的相反数都要小。
    ans = 0
    for i in range(0,h):
        for j in range(0,w):
            ans = max(ans,dp[i][j])
    return ans
"""
堵门情况：
3 4
.#..
#...
....

"""
"""
礼物的最大价值的升级版。
"""
if __name__ == '__main__':
    h,w = map(int,input().split())
    grid = []
    for _ in range(h):
        grid.append(input())
    ans = dp_solve()
    print(ans)